package com.cctc.ware;

import java.util.Map;

/**
 * @Name AbstractCommandManager
 * @Description: 方法查找
 * @Author: lichao
 * @Email: li2chao@126.com
 * @Date: 2024-01-14 17:13:13
 **/
public abstract class AbstractCommandManager {

    /**
     * 1. 创建 Command 实例（抽象方法）
     * @return com.cctc.ware.Command
     * @author lichao
     * @email li2chao@126.com
     * @date 2024/01/14 17:14:14
     */
    public abstract Command createCommand();

    /**
     * 2. 为 Command 实例的处理方法注入参数
     * @param commandState 环境参数
     * @return boolean 处理结果
     * @author lichao
     * @email li2chao@126.com
     * @date 2024/01/14 15:58:28
     */
    public Map<String, Object> process(Map<String, Object> commandState) {
        Command command = createCommand();
        commandState.put("command", command);
        command.setState(commandState);
        return command.execute();
    }

}

